package com.huiquan.framework.base;

import java.io.Serializable;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @ClassName: ReturnData
 * @author 作者
 * @Description: 接口返回数据结构
 * date 2015年1月24日 下午8:09:06
 * @version V1.0
 */
public class ReturnData implements Serializable {

    private static final long serialVersionUID = 1L;
    
    private ReturnCode returnCode; // 编码
    private Map<String, Object> data; // 内容

    /**<p>Title: .</p>
     * <p>Description: </p> 
     * @param returnCode ??
     * @param data ??
     */
    public ReturnData(ReturnCode returnCode, Map<String, Object> data) {
        this.returnCode = returnCode;
        this.data = data;
    }

    
    /** @return the returnCode*/
    public ReturnCode getReturnCode() {
        return returnCode;
    }

    
    /**@param returnCode the returnCode to set*/
    public void setReturnCode(ReturnCode returnCode) {
        this.returnCode = returnCode;
    }

    
    /** @return the data*/
    public Map<String, Object> getData() {
        return data;
    }

    
    /**@param data the data to set*/
    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public static String toJsonString(ReturnData rd) {
        ObjectMapper mapper = new ObjectMapper();
        String s = "";
        try {
            s = mapper.writeValueAsString(rd);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return s;
    }
}